package com.kevin.util;

import ma.glasnost.orika.MapperFacade;
import ma.glasnost.orika.MapperFactory;
import ma.glasnost.orika.impl.DefaultMapperFactory;

import java.util.List;

/**
 * kevin<br/>
 * 2020/10/26 12:58<br/>
 */
public class BeanUtil {

    private static final MapperFacade mapperFacade;

    static {
        MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
        mapperFacade = mapperFactory.getMapperFacade();
    }

    public static <S, D> D map(S source, Class<D> clazz) {
        return mapperFacade.map(source, clazz);
    }

    public static <S, D> List<D> mapAsList(List<S> sourceList, Class<D> clazz) {
        return mapperFacade.mapAsList(sourceList, clazz);
    }
}
